<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Email_Model extends CI_Model{
    function __construct()
    {
        parent::__construct();
    }
    function getAllData($num,$offset){
        $query = $this->db->get('email',$num,$offset);
      
        return $query->result();  
    } 
     function get_object($id)
    {
        $query = $this->db->get_where('email', array('email_id' =>$id));
        return $query->row();
    }
    function getNumData(){
        $query = $this->db->get('email');
        return $query->num_rows();
    }
   
   function saveData($email_id,$data){
             if($email_id!=0){
                    $this->db->where('email_id',$email_id);
                    if($this->db->update('email',$data)){
                         return true;
                    }else{
                         return false;
                    }
             }else{
                    if($this->db->insert('email',$data)){
                        return true;
                        
                    }else{
                        return false;
                    }
            }
    }
	function delete($id){
          $this->db->where('email_id',$id);
          $query = $this->db->delete('email');
          if($query){
              return true;
          }else{
              return false;
          }
    }
	function deleted($id){
          $this->db->where('email_id',$id);
		  $data=array('bl_active'=>'-1');
          $query = $this->db->update('email',$data);
          if($query){
              return true;
          }else{
              return false;
          }
    }
    function get_num_data(){
			
		 	
            $this->db->where('bl_active <>',-1);
             $query = $this->db->get('email');
             return $query->num_rows();
    }
    function get_all_data($num,$offset)
    {	  
            $this->db->where('email.bl_active <>',-1);
            $query = $this->db->get('email',$num,$offset);
            return $query->result();
    }
    
    
  }
?>
